package com.wanglei.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.wanglei.ssm.dao.ProductDao;
import com.wanglei.ssm.domain.Product;
import com.wanglei.ssm.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 商品服务
 *
 * @author wl
 */
@Service
@Transactional
public class ProductServiceImpl implements ProductService {

    /**
     * 商品数据操作接口
     */
    @Autowired
    private ProductDao productDao;

    @Override
    public List<Product> findAllByPage(Integer page, Integer pageSize) throws Exception {
        PageHelper.startPage(page, pageSize);
        return productDao.findAll();
    }

    @Override
    public void save(Product product) throws Exception {
        productDao.save(product);
    }
}
